#include "framewindow.h"
#include <QPainter>
#include <math.h>

FrameWindow::FrameWindow(QWidget *parent) : QWidget(parent)
{
    startTimer(500);
}

void FrameWindow::paintEvent(QPaintEvent *)
{


    QPainter painter(this);
    QRect rect2=rect();
    if(geometry().top()<0){
        int t=geometry().top();
        int h=geometry().height();
        rect2.setTop(-geometry().top());
        rect2.setHeight(h+t);
    }
    if(geometry().left()<0){
        int t=geometry().left();
        int w=geometry().width();
        rect2.setLeft(-geometry().left());
        rect2.setWidth(w+t);
    }
    int t=5;
    painter.setPen(QPen(QBrush(Qt::red),t));
    if(mShow){
        painter.drawRect(rect2.adjusted(2,2,-10,-3));
    }
}

void FrameWindow::timerEvent(QTimerEvent *)
{
    mShow=!mShow;
    update();
}
